import { defineConfig } from '@vben/vite-config';

import ElementPlus from 'unplugin-element-plus/vite';

export default defineConfig(async () => {
  return {
    application: {},
    vite: {
      plugins: [
        ElementPlus({
          format: 'esm',
        }),
      ],
      server: {
        proxy: {
          '/api': {
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, ''),
            // mock代理目标地址
            //target: 'http://localhost:5320/api',

            // target: 'http://127.0.0.1:4523/m1/1707370-1755660-default/',
            //真实后台地址
            target: 'http://localhost:8080',
            ws: true,
          },
          '/gis/tiles': {
            target: 'http://127.0.0.1:8000',
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/gis\/tiles/, ''),
            ws: true,
          },
          // '/giscopy/tiles': {
          //   target: 'http://127.0.0.1:8000',
          //   changeOrigin: true,
          //   rewrite: (path) => path.replace(/^\/giscopy\/tiles/, ''),
          //   ws: true,
          // }
        },
      },
    },
  };
});
